import request from "@/utils/request";
import type { CoursesCommon } from "./types/coursesType";

// 获取课程管理
export type CoursesCondition = Partial<{
    currentPage: number,
    pageSize: number,
    courseName: string,
    status: number | ''
}>

export type CoursesResult = {
    records: CoursesData[],
    total: number,
    size: number,
    current: number
    pages: number
}

type CoursesData = {
    id: number,
    courseName: string,
    brief: string,
    courseDescription: string,
    teacherId?: string
    totalCourseTime?: string,
    sales: number,
    actualSales: number,
    price: number,
    priceTag: string,
    discount: number,
    discountTag: string,
    courseImgUrl: string,
    shareTitle: string,
    shareDescription: string,
    shareImageTitle: string,
    idNew: boolean,
    isNewDes: string,
    lastOperatorId: string,
    createTime: string,
    autoOnlineTime: string,
    isDel: boolean,
    totalDuration: string,
    seoDescription: string,
    seoKeywords: string,
    seoTitle: string,
    h5Url: string,
    courseListImg: string,
    tag: string,
    status: number,
    sortNum: number,
    brokerageRate: number,
    joinDistribution: number,
    lastNoticeTime: string,
    previewFirstField: string,
    previewSecondField: string,
    distributionPosterImage: string,
    distributionCopywriter: string,
    isGray: boolean,
    sectionDTOS: [],
    teacherDTO: [],
    courseUrl: string,
    topNCourseLesson: [],
    isBuy: boolean,
    lessonUpdateCount: number,
    compareTime: string,
    lastLearnLessonName: string,
    courseDescriptionMarkDown: string,
    activityCourse: boolean,
    activityTime: string,
    activityCourseDTO: []

}

export function getCourses(body: CoursesCondition = {}) {
  return request<CoursesCommon<CoursesResult>>({
  url: '/boss/course/getQueryCourses',
    method: 'post',
    data: body
  })
  }